package com.hp_dzzl.mixin.mcr.unusualend.entity;

import net.mcreator.unusualend.entity.EndstoneGolemEntity;
import net.mcreator.unusualend.procedures.EndstoneGolemEntityIsHurtProcedure;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; // 导入LivingEntity
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(
        value = EndstoneGolemEntity.class,
        remap = false
)
public abstract class EndstoneGolemEntityMixin extends LivingEntity { // 继承LivingEntity
    protected EndstoneGolemEntityMixin(EntityType<? extends LivingEntity> p_20966_, Level p_20967_) {
        super(p_20966_, p_20967_);
    }

    /**
     * @author 你的名字
     * @reason 取消所有伤害免疫，同时保留原受伤逻辑
     */
    @Overwrite
    public boolean hurt(DamageSource damagesource, float amount) {
        // 1. 保留原受伤逻辑
        EndstoneGolemEntity thisGolem = (EndstoneGolemEntity) (Object) this;
        double x = thisGolem.getX();
        double y = thisGolem.getY();
        double z = thisGolem.getZ();
        Level world = thisGolem.level();
        Entity sourceentity = damagesource.getEntity();
        EndstoneGolemEntityIsHurtProcedure.execute(world, x, y, z, thisGolem, sourceentity);

        // 2. 调用LivingEntity的默认hurt方法（父类逻辑）
        return super.hurt(damagesource, amount);
    }
}